package com.liankuan.console.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class CheckParamUtil {


    /**
     * 校验是否为JSON格式
     * @param jsonInString
     * @return
     */
    public  static boolean isJSONValid(String jsonInString ) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            mapper.readTree(jsonInString);
            return true;
        } catch (IOException e) {
            return false;
        }
    }

    /**
     * 校验是否为数字
     * @param param
     * @return
     */
    public static boolean isNumber(String param){
        return  param.matches("-?[0-9]+.*[0-9]*");
    }
}
